<!DOCTYPE html>
<html>
<head>
  <title>workify</title>
</head>
<body>
  <div id="result1"></div>
  <div id="result2"></div>
  <script type="text/javascript">
    function addWorker(id) {
      const worker = new Worker('./js/worker.js');
      const count = id * 10;
      worker.onmessage = function onmessage(ev) {
        document.getElementById(`result${id}`).innerHTML = ev.data;
        if (ev.data === count) worker.terminate();
      };
      worker.postMessage('start');
    }
    addWorker(1);
    addWorker(2);
    const worker = new Worker('./js/arrayBuffer.js');
    const uInt8Array = new Uint8Array(1024); 
    for (var i = 0; i < uInt8Array .length; ++i) {
      uInt8Array[i] = i;
    }
    worker.postMessage(uInt8Array.buffer, [uInt8Array.buffer]);
  </script>
</body>
</html>
